package com.cskaoyan.market.advice;

import com.cskaoyan.market.exception.AuthenticationException;
import com.cskaoyan.market.exception.ValidationException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @ClassName GlobalExcpetionHandleAdvice
 * @Description: TODO
 * @Author 远志 zhangsong@cskaoyan.onaliyun.com
 * @Date 2023/5/20 10:50
 * @Version V1.0
 **/
@RestControllerAdvice
public class GlobalExceptionHandleAdvice {

    @ExceptionHandler(ValidationException.class)
    public Object handle1(ValidationException exception){
        return exception.getMessage();
    }

    @ExceptionHandler(AuthenticationException.class)
    public Object error1(AuthenticationException exception){
        //自定义返回类型即可
        return exception.getMessage();
    }
}
